/*     */ package dm.jdbc.rowset;
/*     */ 
/*     */ import java.io.Serializable;
/*     */ import java.util.Collection;
/*     */ import java.util.Vector;
/*     */ 
/*     */ public class DmdbRow implements Serializable, Cloneable
/*     */ {
/*     */   private int m_colCnt;
/*     */   private Object[] m_colValue;
/*     */   private Object[] m_colChangedValue;
/*     */   private boolean[] m_colChanged;
/*     */   private boolean[] m_colOrigNull;
/*     */   private boolean m_rowUpdated;
/*     */   private boolean m_rowInserted;
/*     */   private int m_colInsertedCnt;
/*     */   private boolean m_rowDeleted;
/*     */   
/*     */   public DmdbRow(int cnt)
/*     */   {
/*  21 */     this.m_colCnt = cnt;
/*  22 */     this.m_colValue = new Object[cnt];
/*  23 */     this.m_colChangedValue = new Object[cnt];
/*  24 */     this.m_colChanged = new boolean[cnt];
/*  25 */     this.m_colOrigNull = new boolean[cnt];
/*  26 */     this.m_rowUpdated = false;
/*  27 */     this.m_rowInserted = false;
/*  28 */     this.m_colInsertedCnt = 0;
/*  29 */     this.m_rowDeleted = false;
/*     */   }
/*     */   
/*     */   public DmdbRow(int cnt, boolean insert) {
/*  33 */     this(cnt);
/*     */     
/*  35 */     this.m_rowInserted = insert;
/*     */   }
/*     */   
/*     */   public DmdbRow(int cnt, Object[] vals) {
/*  39 */     this(cnt);
/*     */     
/*  41 */     System.arraycopy(vals, 0, this.m_colValue, 0, cnt);
/*     */   }
/*     */   
/*     */   public Object getColumn(int col) {
/*  45 */     return this.m_colValue[col];
/*     */   }
/*     */   
/*     */   public Object getChangedColumn(int col) {
/*  49 */     return this.m_colChangedValue[col];
/*     */   }
/*     */   
/*     */   public Object[] getOriginalRow() {
/*  53 */     return this.m_colValue;
/*     */   }
/*     */   
/*     */   public boolean isOriginalNull(int col) {
/*  57 */     return this.m_colOrigNull[col];
/*     */   }
/*     */   
/*     */   public boolean isOriginalWithNull() {
/*  61 */     boolean withNull = false;
/*  62 */     for (int i = 0; i < this.m_colCnt; i++) {
/*  63 */       if (isOriginalNull(i)) {
/*  64 */         withNull = true;
/*  65 */         break;
/*     */       }
/*     */     }
/*  68 */     return withNull;
/*     */   }
/*     */   
/*     */   void setOriginalNull(int col, boolean flag) {
/*  72 */     this.m_colOrigNull[col] = flag;
/*     */   }
/*     */   
/*     */   public void setColumnValue(int col, Object val) {
/*  76 */     this.m_colValue[col] = val;
/*     */     
/*  78 */     if (this.m_rowInserted)
/*  79 */       this.m_colInsertedCnt += 1;
/*     */   }
/*     */   
/*     */   public void updateColumnValue(int col, Object nval) {
/*  83 */     this.m_colChanged[col] = true;
/*  84 */     this.m_colChangedValue[col] = nval;
/*     */     
/*  86 */     if (this.m_rowInserted)
/*  87 */       this.m_colInsertedCnt += 1;
/*     */   }
/*     */   
/*     */   public boolean isColumnChanged(int col) {
/*  91 */     return this.m_colChanged[col];
/*     */   }
/*     */   
/*     */   public void insertRow() {
/*  95 */     System.arraycopy(this.m_colChangedValue, 0, this.m_colValue, 0, this.m_colCnt);
/*     */     
/*  97 */     this.m_colChanged = null;
/*  98 */     this.m_colChanged = new boolean[this.m_colCnt];
/*     */     
/* 100 */     this.m_colChangedValue = null;
/* 101 */     this.m_colChangedValue = new Object[this.m_colCnt];
/*     */     
/* 103 */     this.m_colInsertedCnt = 0;
/*     */   }
/*     */   
/*     */   public boolean isRowDeleted() {
/* 107 */     return this.m_rowDeleted;
/*     */   }
/*     */   
/*     */   public boolean isRowInserted() {
/* 111 */     return this.m_rowInserted;
/*     */   }
/*     */   
/*     */   public boolean isRowUpdated() {
/* 115 */     if ((this.m_rowDeleted) || (this.m_rowInserted)) {
/* 116 */       return false;
/*     */     }
/* 118 */     for (int i = 0; i < this.m_colCnt; i++) {
/* 119 */       if (this.m_colChanged[i] != 0)
/* 120 */         return true;
/*     */     }
/* 122 */     return this.m_rowUpdated;
/*     */   }
/*     */   
/*     */   public void cancelRowDeletion() {
/* 126 */     this.m_rowDeleted = false;
/*     */   }
/*     */   
/*     */   public void cancelRowUpdates() {
/* 130 */     for (int i = 0; i < this.m_colCnt; i++) {
/* 131 */       this.m_colChanged[i] = false;
/*     */     }
/* 133 */     this.m_colChangedValue = new Object[this.m_colCnt];
/* 134 */     this.m_colInsertedCnt = 0;
/*     */   }
/*     */   
/*     */   public void setRowUpdated(boolean flag) {
/* 138 */     this.m_rowUpdated = flag;
/*     */     
/* 140 */     if (!flag)
/* 141 */       cancelRowUpdates();
/*     */   }
/*     */   
/*     */   public void setRowDeleted(boolean flag) {
/* 145 */     this.m_rowDeleted = flag;
/*     */   }
/*     */   
/*     */   public void setRowInserted(boolean flag) {
/* 149 */     this.m_rowInserted = flag;
/*     */   }
/*     */   
/*     */   public boolean isRowFullyPopulated() {
/* 153 */     if (!this.m_rowInserted) {
/* 154 */       return false;
/*     */     }
/* 156 */     return this.m_colCnt == this.m_colInsertedCnt;
/*     */   }
/*     */   
/*     */   void setUpdatesOriginal() {
/* 160 */     for (int i = 0; i < this.m_colCnt; i++) {
/* 161 */       if (this.m_colChanged[i] != 0) {
/* 162 */         this.m_colValue[i] = this.m_colChangedValue[i];
/* 163 */         this.m_colChangedValue[i] = null;
/* 164 */         this.m_colChanged[i] = false;
/*     */       }
/*     */     }
/* 167 */     this.m_rowUpdated = false;
/*     */   }
/*     */   
/*     */   public Collection toCollection()
/*     */   {
/* 172 */     Vector<Object> columns = new Vector(this.m_colCnt);
/* 173 */     for (int i = 0; i < this.m_colCnt; i++) {
/* 174 */       columns.add(isColumnChanged(i) ? getChangedColumn(i) : getColumn(i));
/*     */     }
/* 176 */     return columns;
/*     */   }
/*     */   
/*     */   public DmdbRow createCopy() {
/* 180 */     DmdbRow row = new DmdbRow(this.m_colCnt);
/* 181 */     System.arraycopy(this.m_colValue, 0, row.m_colValue, 0, this.m_colCnt);
/* 182 */     System.arraycopy(this.m_colChangedValue, 0, this.m_colChangedValue, 0, this.m_colCnt);
/* 183 */     System.arraycopy(this.m_colChanged, 0, row.m_colChanged, 0, this.m_colCnt);
/* 184 */     row.m_colInsertedCnt = this.m_colInsertedCnt;
/* 185 */     row.m_rowDeleted = this.m_rowDeleted;
/* 186 */     row.m_rowInserted = this.m_rowInserted;
/* 187 */     row.m_rowUpdated = this.m_rowUpdated;
/* 188 */     return row;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\rowset\DmdbRow.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */